import {
  ADMIN_ADD_DEPARTMENT,
  ADMIN_ADD_SALARY,
  ADMIN_DELETE_DEPARTMENT,
  ADMIN_DELETE_SALARY,
  ADMIN_DELETE_USER,
  ADMIN_LOAD_ACCESS_TOKEN,
  ADMIN_LOGIN,
  ADMIN_LOGOUT,
  ADMIN_SET_ALL_DEPARTMENT_LIST, ADMIN_SET_CURRENT_DEPARTMENT,
  ADMIN_SET_DEPARTMENT_INFO,
  ADMIN_SET_DEPARTMENT_LIST,
  ADMIN_SET_USER_INFO,
  ADMIN_SET_USER_LIST,
  ADMIN_SET_USER_SALARY_LIST,
  ADMIN_UPDATE_DEPARTMENT_INFO,
  ADMIN_UPDATE_SALARY,
  LOAD_USER_STATE,
  REGISTER_SUCCESS,
  REMEMBER_USER_STATE,
  REMOVE_USER_STATE,
  SAVE_USER_STATE,
  SET_LOGIN_TYPE,
  SET_SALARY_LIST,
  SET_USER_INFO,
} from './action-types'

/**
 * Action 构造器
 * @param type
 * @param data
 * @returns {{data: undefined, type: *}}
 */
export const actionFactory = (type, data = undefined) => ({ type, data })

/*
  UserState Action
 */
export const loadUserState = () => actionFactory(LOAD_USER_STATE)
export const logout = () => actionFactory(REMOVE_USER_STATE)
export const saveUserState = data => actionFactory(SAVE_USER_STATE, data)
export const rememberUserState = data => actionFactory(REMEMBER_USER_STATE, data)
/*
  UserInfoState Action
 */
export const set_user_info = data => actionFactory(SET_USER_INFO, data)
export const set_salary_list = data => actionFactory(SET_SALARY_LIST, data)
/*
  Global Action
 */
export const setRegisterSuccess = data => actionFactory(REGISTER_SUCCESS, data)
export const set_login_type = data => actionFactory(SET_LOGIN_TYPE, data)

/*
  Admin Action
 */
export const admin_login = data => actionFactory(ADMIN_LOGIN, data)
export const admin_logout = () => actionFactory(ADMIN_LOGOUT)
export const admin_load_access_token = () => actionFactory(ADMIN_LOAD_ACCESS_TOKEN)
export const admin_set_user_list = data => actionFactory(ADMIN_SET_USER_LIST, data)
export const admin_delete_user = data => actionFactory(ADMIN_DELETE_USER, data)
export const admin_delete_salary = data => actionFactory(ADMIN_DELETE_SALARY, data)
export const admin_update_salary = data => actionFactory(ADMIN_UPDATE_SALARY, data)
export const admin_add_salary = data => actionFactory(ADMIN_ADD_SALARY, data)
export const admin_set_user_info = data => actionFactory(ADMIN_SET_USER_INFO, data)
export const admin_set_department_info = data => actionFactory(ADMIN_SET_DEPARTMENT_INFO, data)
export const admin_update_department_info = data => actionFactory(ADMIN_UPDATE_DEPARTMENT_INFO, data)
export const admin_delete_department = data => actionFactory(ADMIN_DELETE_DEPARTMENT, data)
export const admin_set_department_list = data => actionFactory(ADMIN_SET_DEPARTMENT_LIST, data)
export const admin_set_user_salary_list = data => actionFactory(ADMIN_SET_USER_SALARY_LIST, data)
export const admin_set_all_department_list = data => actionFactory(ADMIN_SET_ALL_DEPARTMENT_LIST, data)
export const admin_add_department = data => actionFactory(ADMIN_ADD_DEPARTMENT, data)
export const admin_set_current_department = data => actionFactory(ADMIN_SET_CURRENT_DEPARTMENT, data)